import rank0 from '@/assets/images/assignment/right-color.png'
import rank1 from '@/assets/images/assignment/half-color.png'
import rank2 from '@/assets/images/assignment/wrong-color.png'
import rank3 from '@/assets/images/assignment/wait-black.png'

import practice1Icon from '@/assets/images/assignment/practice-1.png'
import practice2Icon from '@/assets/images/assignment/practice-2.png'
import practice3Icon from '@/assets/images/assignment/practice-3.png'
import practice4Icon from '@/assets/images/assignment/practice-4.png'
import dayjs from 'dayjs'

export const returnTypeOptions = [
  {
    value: 1,
    label: '个性错题'
  },
  {
    value: 2,
    label: '高频错题'
  }
]

export const returnQUesTypeOptions = [
  {
    value: 0,
    label: '全部'
  },
  {
    value: 1,
    label: '主观题'
  },
  {
    value: 2,
    label: '客观题'
  }
]

export const rankMap = {
  all_correct: rank0,
  part_correct: rank1,
  incorrect: rank2,
  await_grade: rank3
}

export const overviewCardList = [
  {
    text: '提交率',
    unit: '%',
    rate: 0,
    img: practice2Icon,
    bgc: '#E8F4FF',
    processColor: '#5AADF9',
    list: [
      {
        text: '已交：',
        num: 0,
        unit: '人'
      },
      {
        text: '未交：',
        num: 0,
        unit: '人',
        list: []
      }
    ]
  },
  {
    text: '正确率',
    unit: '%',
    rate: 0,
    img: practice1Icon,
    bgc: '#F0F1FC',
    processColor: '#5466E7',
    list: [
      {
        text: '最高：',
        num: 0,
        unit: '%'
      },
      {
        text: '最低：',
        num: 0,
        unit: '%'
      }
    ]
  },
  {
    text: '客观题正确率',
    unit: '%',
    rate: 0,
    img: practice4Icon,
    bgc: '#FFF5E8',
    processColor: '#F59F30',
    list: [
      {
        text: '最高：',
        num: 0,
        unit: '%'
      },
      {
        text: '最低：',
        num: 0,
        unit: '%'
      }
    ]
  },
  {
    text: '批改完成',
    unit: '%',
    rate: 0,
    img: practice3Icon,
    bgc: '#E7FAEF',
    processColor: '#0CC58D',
    list: [
      {
        text: '已批：',
        num: 0,
        unit: '人'
      },
      {
        text: '未批：',
        num: 0,
        unit: '人',
        list: []
      }
    ]
  }
]

export const handleRate = (rate, num = 1) => Number((rate * 100).toFixed(num))

export const getColorByNum = value => {
  let color = ''
  switch (true) {
    case value >= 80:
      color = '#25A780'
      break
    case value >= 60:
      color = '#ACDB4A'
      break
    default:
      color = '#DC4834'
  }
  return color
}

export const commonDateDisable = time => {
  return time.getTime() <= dayjs().add(-1, 'day').valueOf()
}

export const CLASS_TYPE = {
  AdminClass: 1,
  TeachClass: 2,
  TargetClass: 3,
  SmartClass: 4
}

// 多选题给分策略
export const STRATEGY_OPTIONS = [
  {
    label: '少选给一半分，多选不给分',
    value: 1,
    minScore: 1
  },
  {
    label: '少选给1分，多选不给分',
    value: 2,
    minScore: 1
  },
  {
    label: '少选给2分，多选不给分',
    value: 3,
    minScore: 2
  },

  {
    label: '少选给3分，多选不给分',
    value: 4,
    minScore: 3
  }
  // {
  //   label: '对一个选项，给1分，多选不给分',
  //   value: 5,
  //   minScore: 1
  // },

  // {
  //   label: '对一个选项，给2分，多选不给分',
  //   value: 6,
  //   minScore: 2
  // },

  // {
  //   label: '对一个选项，给3分，多选不给分',
  //   value: 7,
  //   minScore: 3
  // }
]

export const getType6Text = (type, sum) => {
  const level = ['full_score', 'gt_half', 'lt_half', 'zero_score']
  let text = ''
  switch (type) {
    case level[0]:
      text = sum
      break
    case level[1]:
      text = `≥${Number(sum * 0.5).toFixed(1)}`
      break
    case level[2]:
      text = `<${Number(sum * 0.5).toFixed(1)}`
      break
    case level[3]:
      text = 0
  }
  return text
}
